#region BLL VERSION  2.6
/* ChiNhanh
 *
 * Author: LANNT    
 * Copyright: (c) - LANNT 
 * Created:   23/08/2012 10:03:37 PM
 * Last modify: 2012-08-01 11:15 PM 
 * Note   :   Changes to this file may cause incorrect behavior and will be lost if
*            the code is regenerated.
*/
#endregion

#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using GQ.Utils;

using Chili.Opf3;
using Chili.Opf3.Relations;
using Chili.Opf3.DynamicProperties;
#endregion

namespace GQ.BLL.QuanLyKho
{
    #region ChiNhanh
    [Serializable]
    [Persistent("CHINHANH", PoolSize = 10)]
    public partial class ChiNhanh
    {
        #region Members
        private Guid _id = Guid.NewGuid();
        private string _ma = null;
        private string _ten = null;
        private string _ghichu = null;
        private Guid? _companyid = null;
        #endregion

        #region Public Properties

        [Field("ID", Identifier = true, AllowDBNull = false)]
        public Guid ID
        {
            get { return _id; }
            set { _id = value; }
        }

        [Field("MA")]
        public string Ma
        {
            get { return _ma; }
            set { _ma = value; }
        }

        [Field("TEN")]
        public string Ten
        {
            get { return _ten; }
            set { _ten = value; }
        }

        [Field("GHICHU")]
        public string GhiChu
        {
            get { return _ghichu; }
            set { _ghichu = value; }
        }

        [Field("COMPANYID")]
        public Guid? CompanyID
        {
            get { return _companyid; }
            set { _companyid = value; }
        }

        #endregion
        #region Methods Install
        public ChiNhanh LoadByID()
        {
            return DbContext.ObjectContext.GetObject<ChiNhanh>("ID={0}", ID);
        }
        public static ChiNhanh LoadByID(Guid id)
        {
            return DbContext.ObjectContext.GetObject<ChiNhanh>("ID={0}", id);
        }
        public void DeleteByID(Guid id)
        {
            ID = id;
            Chili.Opf3.ObjectInfo objInfo = GQ.Utils.DbContext.ObjectContext.GetObjectInfo(this);
            objInfo.ObjectState = Chili.Opf3.ObjectStates.Loaded;
            objInfo.MarkForDeletion = true;
            DbContext.ObjectContext.PersistChanges<ChiNhanh>(this);
        }
        public ChiNhanh LoadBy(string conditions, params object[] parameter)
        {
            return DbContext.ObjectContext.GetObject<ChiNhanh>(conditions, parameter);
        }
        public void Save()
        {
            DbContext.ObjectContext.PersistChanges<ChiNhanh>(this);
        }
        public void Delete()
        {
            DbContext.ObjectContext.MarkForDeletion(this);
            DbContext.ObjectContext.PersistChanges<ChiNhanh>(this);
        }
        #endregion Methods Install
        #region Methods Collection
        public static IList<ChiNhanh> LoadAll()
        {
            return DbContext.ObjectContext.GetObjectSet<ChiNhanh>();
        }
        public static IList<ChiNhanh> LoadAll(string sortby)
        {
            return DbContext.ObjectContext.GetObjectSet<ChiNhanh>("Sortby " + sortby);
        }
        public static IList<ChiNhanh> LoadAllBy(string conditions, params object[] parameter)
        {
            return DbContext.ObjectContext.GetObjectSet<ChiNhanh>(conditions, parameter);
        }
        public static IList<ChiNhanh> LoadAllBy(Chili.Opf3.Query.SqlQuery query)
        {
            return DbContext.ObjectContext.GetObjectSet<ChiNhanh>(query);
        }
        public static void SaveAll(IList<ChiNhanh> collection)
        {
            foreach (ChiNhanh item in collection)
            {
                item.Save();
            }
        }
        public static void DeleteAll(IList<ChiNhanh> collection)
        {
            foreach (ChiNhanh item in collection)
            {
                item.Delete();
            }
        }
        #endregion Methods Collection

    }
    #endregion

}
